how to deploy project with jenkins pipeline script on kubernetes1.19¶
install pipeline plugin, git parameter plugin
get credentialsId from manage credentials
add docker repository in maven settings.xml
<server> <id>docker-repo</id> <username>user</username> <password>password</password> <configuration> <email>eamil</email> </configuration> </server>create image pull secret in kubernetes, add imagePullSecrets in k8s yaml
kubectl create secret docker-registry chenshi --docker-username=user --docker-password=password --docker-email=emailspec: containers: - name: nginx imagePullSecrets: - name: myregistrykeypipeline script
pipeline { agent any stages { stage('checkout') { steps { dir('/projects/project1/') { git branch: "${branch}", credentialsId: 'from manage credentials', url: 'https://chenshi.de/projects/project1/' } } } stage('build') { steps { dir('/projects/project1/') { sh''' mvn clean package -Ddocker-image.tag=${dockerTag} -DpushImage #rm -rf /projects/project1/dist/ && yarn && yarn build && docker build -t chenshi.de/project:${tag} . && docker push chenshi.de/project:${tag} ''' } } } stage('deploy') { steps { sh ''' /scrips/project1.sh ${tag} ''' } } } }references:
http://dmp.fabric8.io/#authentication
https://www.ibm.com/support/knowledgecenter/en/SSBS6K_2.1.0.3/manage_images/imagepullsecret.html